﻿Imports ccapps.persistent.ChangeCustomerStatus

Public Class ChangeCustomerStatus
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Session("user") = "" Or Session("user") Is Nothing Then
            Session("message") = "!!Session Timeout!!,Tekrar Giriş Yapmalısınız"
            Response.Clear()
            Response.Status = "302 Object Moved"
            Response.RedirectLocation = "CX_Exception.aspx"
            Response.End()
        End If

        DrpNewStatusReason.Items.Clear()
        Dim dt As DataTable = DeactivationReason()
        'DrpNewStatusReason.DataSource = dt
        'DrpNewStatusReason.DataBind()
        If dt.Rows.Count > 0 Then
            For Each dr2 As DataRow In dt.Rows
                DrpNewStatusReason.Items.Add(New ListItem(dr2("desc").ToString(), dr2("id").ToString())) 'rs_desc ve rscode Databasedeki sql variablelarının isimleri' 
            Next
        End If



    End Sub

    Protected Sub SMSISDN_Click(sender As Object, e As EventArgs) Handles SMSISDN.Click
        Try
            clear()
            TxtCustcode.Text = ""
            If TxtMsisdn.Text.Length = 0 Then
                Me.Page.RegisterStartupScript("javascript", "<script language=""javascript"">alert('MSISDN Alanının Girilmesi Zorunludur.');</script>")
            Else

                If Not TxtMsisdn.Text.Length = 10 Then
                    Me.Page.RegisterStartupScript("javascript", "<script language=""javascript"">alert('MSISDN Alanı 10 Karakter İçermelidir.');</script>")
                Else



                    Dim dt As DataTable = GetCustInfoFromMSISDN(TxtMsisdn.Text)
                    If dt.Rows.Count > 0 Then

                        LblCustomer.Text = dt.Rows(0)("NAME").ToString() + "   " + dt.Rows(0)("LASTNAME").ToString() + "   " + dt.Rows(0)("CITY").ToString()
                        LblCsid.Text = dt.Rows(0)("CSID").ToString()
                        LblCustcodeMSısdn.Text = TxtMsisdn.Text
                        LblStatus.Text = dt.Rows(0)(3).ToString()
                        confirmTable.Visible = True
                    Else
                        ErrorMes.Text = "Girmiş Olduğunuz MSISDN'e Ait Veri Bulunamamıştır"
                        confirmTable.Visible = False
                    End If
                End If
            End If
        Catch ex As Exception
            ErrorMes.Text = "Girmiş Olduğunuz MSISDN'e Ait Veri Bulunamamıştır"
        End Try
       




    End Sub

    Protected Sub SCustCode_Click(sender As Object, e As EventArgs) Handles SCustCode.Click
        Try
            clear()
            TxtMsisdn.Text = ""


            If TxtCustcode.Text = "" Then
                Me.Page.RegisterStartupScript("javascript", "<script language=""javascript"">alert('CustCode Alanın Girilmesi Zorunludur.');</script>")
            Else

                Dim dt As DataTable = GetCustInfoFromCustcode(TxtCustcode.Text)
                If dt.Rows.Count > 0 Then
                    'Table2.Visible = True
                    LblCustomer.Text = dt.Rows(0)("NAME").ToString() + "   " + dt.Rows(0)("LASTNAME").ToString() + "   " + dt.Rows(0)("CITY").ToString()
                    LblCustcodeMSısdn.Text = TxtCustcode.Text
                    LblStatus.Text = dt.Rows(0)(4).ToString()
                    LblCsid.Text = dt.Rows(0)("CSID").ToString()
                    confirmTable.Visible = True
                Else
                    ErrorMes.Text = "Girmiş Olduğunuz CUSTCODE'a Ait Veri Bulunamamıştır"
                    confirmTable.Visible = False
                End If


            End If
        Catch ex As Exception
            ErrorMes.Text = "Girmiş Olduğunuz CUSTCODE'a Ait Veri Bulunamamıştır"
        End Try
        
    End Sub

    Protected Sub SCustCode0_Click(sender As Object, e As EventArgs) Handles SCustCode0.Click
        Try
            Dim dt As DataTable = DeactivationCustomer(Convert.ToInt32(LblCsid.Text), Convert.ToInt32(DrpNewStatusReason.SelectedValue))
            If dt.Rows.Count > 0 Then
                If dt.Rows(0)(0).ToString = "1" Then
                    Me.Page.RegisterStartupScript("javascript", "<script language=""javascript"">alert('İşlem Başarıyla Gerçekleşmiştir.');</script>")
                Else
                    Me.Page.RegisterStartupScript("javascript", "<script language=""javascript"">alert('İşlem Gerçekleşmemiştir.');</script>")
                End If

            Else
                Me.Page.RegisterStartupScript("javascript", "<script language=""javascript"">alert('İşlem Gerçekleşmemiştir.');</script>")
            End If
        Catch ex As Exception
            Me.Page.RegisterStartupScript("javascript", "<script language=""javascript"">alert('İşlem Gerçekleşmemiştir.');</script>")
        End Try
        

    End Sub
    Public Sub clear()
        LblCsid.Text = ""
        LblCustcodeMSısdn.Text = ""
        LblCustomer.Text = ""
        LblStatus.Text = ""
        LblCsid.Text = ""
        ErrorMes.Text = ""
        confirmTable.Visible = False


    End Sub
End Class